package br.com.ilha.action;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import br.com.ilha.bean.Lei;
import br.com.ilha.dao.LeiDao;

public class LeiAction {

	private Lei lei;
	private List<Lei> leis;

	@Action(value="adicionarLei", results = {
			@Result(name="ok", location="/teste.html")
	})
	public String adicionarLei(){
		LeiDao.adiciona(lei);
		return "ok";
	}

	@Action(value="listarLeis", results = {
			@Result(name="ok", location="/listaLeis.jsp")
	})
	public String listarLeis(){

		LeiDao l = new LeiDao();
		this.leis = l.listAll();
		System.out.println(leis);
		return "ok";

	}

	public List<Lei> getLeis() {
		return leis;
	}
	
	public Lei getLei() {
		return lei;
	}

	public void setLei(Lei lei) {
		this.lei = lei;
	}
}
